package com.atguigu.gmall.item.api;

import ch.qos.logback.core.pattern.util.RegularEscapeUtil;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: atguigu
 * @create: 2023-09-02 16:13
 */
@RestController
@RequestMapping("/api/item")
public class ItemApiController {

    @Autowired
    private ItemService itemService;

    /**
     * 汇总渲染商品详情页面所需要数据模型
     *
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}")
    public Result getSkuInfo(@PathVariable("skuId") Long skuId) {
        Map<String, Object> mapResult = itemService.getSkuInfo(skuId);
        return Result.ok(mapResult);
    }
}
